﻿@using PagedList.Mvc;
@model PagedList.IPagedList<OT.Data.sp_CustomeQuestionList_Result>

@{
    ViewBag.Title = "Question";
}
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i></button>
        <h3 id="myModalLabel">Custom Question</h3>
    </div>
    <div>
        <div class="modal-body" style="max-height: 350px; overflow-y: scroll;">
            <table id="QuestionTable">
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            <div class="form-vertical" role="form">
                                <div class="form-group" id="divCategoryName">
                                    <div class="col-lg-1">
                                        <input type="checkbox" id = "chkTbl" value="@item.QuestionID"/>
                                    </div>
                                    <div class="col-lg-10">
                                        @Html.DisplayFor(modelItem => item.QuestionName)
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                }
                <tr></tr>
            </table>
        </div>
        <div class="modal-footer">
            <button class="btn btn-default" type="submit" id="btnDone"><i class="icon-cog"></i>Done</button>
            <button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="icon-off"></i>Cancel</button>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {

    });

    $("#btnDone").click(function (e) {
        var selectedRecord = new Array();
        try {
            var table = document.getElementById("QuestionTable");
            var rowCount = table.rows.length;
            var j = 0;
            for (var i = 0; i < rowCount; i++) {
                var chkbox = $(table).find("input#chkTbl")[i];
                if (chkbox != undefined && chkbox.checked) {
                    id = chkbox.getAttribute("value");
                    selectedRecord[j] = id;
                    j += 1;
                }
            }
            $("#QuetionIDs").val(selectedRecord);
            if (selectedRecord.length != 0) {
                $("#TotalQuestion").val(selectedRecord.length);
            }
        } catch (e) {
            alert(e);
        }
        $('#modalQsDiv').modal('hide');
        return false;
    });
</script>


